package asteroids.model.programs.parsing.expressions;

import java.util.Map;

import asteroids.model.Ship;
import asteroids.model.programs.parsing.types.DoubleLiteral;
import asteroids.model.programs.parsing.types.Type;

/**
 * A class of cosinus expressions.
 * A cosinus expression involves a cosinus operator applied to only one operand.
 * 
 * @author Thijs Dieltjens - Wim Konings
 * @version 2.0
 */
public class CosExpr extends MathematicalExpr {

	public CosExpr(Expression expr,int line, int column) {
		super(expr, line, column);
	}

	@Override
	public Type eval(Ship ship, Map<String, Type> globals) {
		if(getOperand().eval(ship, null) instanceof DoubleLiteral) {
			return new DoubleLiteral(Math.cos( ((DoubleLiteral) super.getOperand().eval(ship, null)).getValue() ));
		}
		return new DoubleLiteral();
	}
}
